
from chaotic import chaotic
from live import join, bottom, top, assign, iota, no_assign

succ = {0: set(),
        1: set([0]),
        2: set([1,5]),
        3: set([2]),
        4: set([3]),
        5: set([4]),
        }

tr = {(1,0): lambda live: assign(live, 'a', ('0', ())),
        (2,1): lambda live: assign(live, 'b', ('+', (('a',()), ('1',())))),
        (3,2): lambda live: assign(live, 'c', ('+', (('c',()), ('b',())))),
        (4,3): lambda live: assign(live, 'a', ('*', (('b',()), ('2',())))),
        (5,4): lambda live: no_assign(live, ('<', (('c',()), ('100',())))),
        (2,5): lambda live: assign(live, 'b', ('+', (('a',()), ('1',())))),
          }

tr_txt = {(1,0): "a = 0",
          (2,1): "L1: b = a + 1",
          (3,2): "c = c + b",
          (4,3): "a = b * 2",
          (5,4): "if  c < 100 goto L1",
          (2,5): "L1: b = a + 1",
          }

chaotic(succ, 5, set(['c']), join, bottom, tr, tr_txt, "live_prog1.png")

#0
#1     a = 0;
#2 L1: b = a + 1;
#3     c = c + b;
#4     a = b * 2;
#5     if  c < 100 goto L1
#6     /* assume that c is live here */
